package com.blc.timing;

import com.blc.service.AccessTokenService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Scheduled;


// 在配置中用Component是不是不太好
@Configuration
@Slf4j
public class AccessTokenScheduled {
    @Autowired
    AccessTokenService accessTokenService;

    // 定时获取access_token 放到线程中
    // 放到redis判断redis中有没有这样最好但是项目要是集成redis太麻烦了
    @Scheduled(cron = "0 */90 * * * ?")
    public void getAccessToken(){
        String accessToken = accessTokenService.getAccessToken();
        log.info("定时任务调用成功 accessToken:{}",accessToken);
    }

}
